package flc.ast.adapter;


import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.ConvertUtils;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.stark.picselect.entity.SelectMediaEntity;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;
import stark.common.basic.utils.TimeUtil;

public class VideoAdapter extends StkProviderMultiAdapter<SelectMediaEntity> {
    public VideoAdapter() {
        addItemProvider(new StkSingleSpanProvider(126));
        addItemProvider(new VideoProvider());
    }

    private class VideoProvider extends BaseItemProvider<SelectMediaEntity> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_video;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, SelectMediaEntity selectMediaEntity) {
            Glide.with(getContext()).load(selectMediaEntity.getPath())
                    .into((ImageView) baseViewHolder.getView(R.id.ivVideoItemImg));
            baseViewHolder.setText(R.id.tvVideoItemName, selectMediaEntity.getMediaName());
            baseViewHolder.setText(R.id.tvVideoItemSize, ConvertUtils.byte2FitMemorySize(selectMediaEntity.getSize(), 1));
            baseViewHolder.setText(R.id.tvVideoItemDuration, TimeUtil.getHHmmss(selectMediaEntity.getDuration()));
        }
    }

}
